package com.mfangsoft.zhuangjialong.integration.newGift.controller;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mfangsoft.zhuangjialong.common.model.Page;
import com.mfangsoft.zhuangjialong.common.model.ResponseMessage;
import com.mfangsoft.zhuangjialong.common.utils.SysConstant;
import com.mfangsoft.zhuangjialong.integration.gift.model.BaseGift;
import com.mfangsoft.zhuangjialong.integration.newGift.service.NewGiftService;

@Controller
@RequestMapping("/server")
public class NewGiftController {
	
	@Autowired
	private NewGiftService newGiftServiceImpl;
	
	/**
	 * 查看礼品库列表
	 * @param page
	 * @return
	 * @throws ParseException
	 */
	@RequestMapping(value="/selectNewGiftActivityPage",method=RequestMethod.POST)
	@ResponseBody
	@CrossOrigin
	public Page<Map<String, Object>> selectNewGiftActivityPage(@RequestBody Page<Map<String, Object>> page) throws ParseException{
		try {
			Page<Map<String, Object>> list = newGiftServiceImpl.selectNewGiftActivityPage(page);
			return list;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		return page;
	}
	
	/**
	 * 分公司查看礼品库
	 * @return
	 * @throws ParseException
	 */
	@RequestMapping(value="/selectNewGiftActivityList",method=RequestMethod.POST)
	@ResponseBody
	@CrossOrigin
	public  ResponseMessage<List<Map<String,Object>>> selectNewGiftActivityList() throws ParseException{
		
		
		ResponseMessage<List<Map<String,Object>>> message = new ResponseMessage<List<Map<String,Object>>>();
		try {
			List<Map<String,Object>> list = newGiftServiceImpl.selectNewGiftActivityList();
			message.setCode(SysConstant.SUCCESS_CODE);
			message.setMessage(SysConstant.SUCCESS_MSG);
			message.setResult(list);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			message.setCode(SysConstant.FAILURE_CODE);
			message.setMessage(SysConstant.FAILURE_MSG);
		}
		return message;
	}
}
